<template>
  <div>
    {{ $route.params.id }}
    <div class="topimg">
      <img :src="this.$route.query.img" alt />
      <div class="smallimg">
        <img :src="this.$route.query.smallimg" alt />
      </div>
      <div class="return">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">
            <van-icon name="arrow-left" color="red" size="20px" />
          </el-breadcrumb-item>
        </el-breadcrumb>
      </div>
    </div>
    <div class="text">
      <h1>{{ this.$route.query.name }}</h1>
      <p>
        <span>评价4.9</span>
        <span>月售540单</span>
        <span>蓝骑士专送约30分钟</span>
      </p>
      <h3>
        <span>30减12</span>
        <span>配送费优惠</span>
        <b>3个优惠</b>
      </h3>
      <p>公告：尊敬的顾客您好，本店去冰产品仍有少量冰渣 谢谢</p>
    </div>
    <div class="tabs">
      <van-tabs color="rgb(35, 149, 255)" line-width="30px">
        <van-tab title="点餐">
          <h5>商家推荐</h5>
          <div class="swiper">
            <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
              <van-swipe-item>
                <img :src="this.$route.query.swiperimg1" alt />
                <img :src="this.$route.query.swiperimg2" alt />
                <img :src="this.$route.query.swiperimg3" alt />
              </van-swipe-item>
              <van-swipe-item>
                <img :src="this.$route.query.swiperimg3" alt />
                <img :src="this.$route.query.swiperimg2" alt />
                <img :src="this.$route.query.swiperimg1" alt />
              </van-swipe-item>
            </van-swipe>
          </div>
          <el-tabs :tab-position="tabPosition" style="height: 100%;">
            <el-tab-pane label="热销">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon  @click="add" name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="优惠">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="扬之物">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="龙井上新">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="果味茶系列">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="珍珠奶茶">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="香梅系列">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="奶茶味">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="冬瓜系列">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>
            <el-tab-pane label="醇品裸茶">
              <div class="tab" v-for="item in shop" :key="item.id">
                <div class="tabimg">
                  <img :src="item.smallimg" alt />
                </div>
                <div class="tabtext">
                  <h5>{{ item.name }}</h5>
                  <p>香辣牛肉面+荷包蛋+鱼丸汤，最完美的营养搭配，不要等待，不要离开。主要原料：面条,牛肉,鸡蛋,鱼丸</p>
                  <p>
                    <span>月售3份</span>
                    <span>好评率0.0%</span>
                  </p>
                  <div class="add">
                    <h4>￥22.98</h4>
                    <van-icon name="add" size="25px" color="rgb(35, 149, 255)" />
                  </div>
                </div>
              </div>
            </el-tab-pane>    
          </el-tabs>
        </van-tab>
        <van-tab title="评价">
          <div class="pingjia">
            <span>4.7</span>
            <small>
              味道:
              <b>4.73</b>
            </small>
            <small>
              包装:
              <b>4.81</b>
            </small>
            <small>
              配送:
              <b>4.76</b>
            </small>
          </div>
        </van-tab>
        <van-tab title="商家">
          <div class="sj">
            <div class="sjimg">
              <img
                src="https://cube.elemecdn.com/1/d8/59572aecaf5c56cb599fa23a1c83fpng.png?x-oss-process=image/format,webp/resize,w_460,h_260,m_fixed"
                alt
              />
            </div>
            <h2>村上一屋·寿司匠人</h2>
            <p>品牌创始于2016年1月，团队坚持“心心在一艺，其艺必工，心心在一职，其职必举”的工匠精神，用心做好...</p>
          </div>
        </van-tab>
      </van-tabs>
    </div>
    <div class="fixed">
      <div class="icon">
        <van-icon name="shopping-cart" color="#444" size="30px"/>
      </div>
      <p>满25减8元，满35减15元，满50减25元</p>
      <div class="fixbot">
        <div class="fixleft">
          <h3>未选购商品</h3>
          <h1>另需配送费1元</h1>
        </div>
        <div class="fixright">
          <button>￥20起送</button>
        </div>
      </div>
      
    </div>
  </div>
</template>

<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      activeKey: 0,
      tabPosition: "left", 
    };
  },
  methods: {
    add() {
      console.log('点击了')
    }
  },
  // 得到数据源里的数据必须用computed
  computed: {
    ...mapState(["shop"]),
  },
  async mounted() {
    let url = "http://localhost:8080/data/shop.json";
    let res = await this.$axios.get(url);
    this.$store.dispatch("shop", res.data);
  },
  created() {
    // this.$bus.$emit("footernav", false);
    this.$store.dispatch("setshow", false);
  },
  beforeDestroy() {
    this.$bus.$emit("footernav", true);
    // this.$store.dispatch("setshow", true);
  },
};
</script>

<style lang="less" scoped>
.topimg {
  width: 100%;
  height: 125px;
  position: relative;
  img {
    width: 100%;
    height: 100%;
  }
  .smallimg {
    width: 75px;
    height: 75px;
    position: absolute;
    top: 50%;
    left: 40%;
    border: 1px solid #f5f5f5;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .return {
    position: absolute;
    top: 5px;
    left: 5px;
  }
}
.text {
  text-align: center;
  margin-top: 30px;
  h1 {
    width: 230px;
    height: 25px;
    overflow: hidden;
    font-size: 20px;
    font-weight: 700;
    margin-left: 70px;
    text-overflow: ellipsis;
  }
  p {
    text-align: center;
    font-size: 11px;
    margin-top: 5px;
    color: #666;
    span {
      margin-right: 5px;
    }
  }
  h3 {
    font-weight: normal;
    font-size: 11px;
    color: #666;
    text-align: center;
    margin-top: 5px;
    span {
      border: 1px solid #f5f5f5;
      color: rgb(255, 75, 51);
      margin-right: 10px;
    }
    b {
      margin-left: 80px;
      font-weight: normal;
    }
  }
}
h5 {
  padding-left: 4.266667vw;
  color: #333;
  font-size: 16px;
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 0.266667rem;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 20px;
  line-height: 150px;
  text-align: center;
  background-color: #fff;
}
.swiper {
  img {
    width: 120px;
    height: 120px;
  }
}
h2 {
  text-align: center;
  font-size: 30px;
  color: chartreuse;
}
.pingjia {
  height: 70px;
  text-align: center;
  margin-top: 20px;
  border-bottom: 10px solid #f5f5f5;
  span {
    color: #ff6000;
    font-size: 50px;
  }
  small {
    color: #666;
    margin-left: 10px;
    b {
      font-size: 22px;
    }
  }
}
.sj {
  padding: 10px;
  margin-top: 20px;
  .sjimg {
    width: 340px;
    height: 170px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  h2 {
    color: #000;
    font-size: 16px;
    text-align: left;
    margin-top: 20px;
  }
  p {
    margin-top: 20px;
    color: #666;
    font-size: 14px;
  }
}
.tab {
  display: flex;
  justify-content: space-around;
  height: 95px;
  margin-bottom: 20px;
  .tabimg {
    width: 95px;
    img {
      width: 100%;
      height: 100%;
    }
  }
  .tabtext {
    width: 183px;
    height: 95px;
    h5 {
      // width: 95px;
      font-weight: 700;
      overflow: hidden;
      font-size: 16px;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    p {
        font-size: 12px;
        color: #999;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin-left: 15px;
      }
      .add {
        display: flex;
        justify-content: space-between;
        h4 {
          color: rgb(255, 83, 57);
          font-size: 18px;
          font-weight: normal;
          margin-left: 15px;
        }
        .van-icon {
          margin-right: 10px;
        }
      }
  }
}
.fixed {
  width: 100%;
  height: 60px;
  position: fixed;
  bottom: 0px;
  left: 0;
  z-index: 1000;
  .icon {
    width: 50px;
    height: 50px;
    line-height: 50px;
    position: fixed;
    bottom: 0px;
    left: 15px;
    border: 1px solid #444;
    border-radius: 50%;
    text-align: center;
    background-color: #363636;
    .van-icon {
      margin-top: 10px;
    }
  }
  p {
    height: 20px;
    line-height: 20px;
    background-color: #fffad6;
    border-top: 1px solid #f9e8a3;
    text-align: center;
    font-size: 12px;
  }
  .fixbot {
    height: 48px;
    display: flex;
    justify-content: space-between;
    background-color: #363636;
    z-index: 1000;
    align-items: center;
    .fixleft {
      width: 190px;
      color: #999;
      margin-left: 80px;
      h3 {
        font-size: 14px;
      }
      h1 {
        font-size: 12px;
        color: #999;
      }
    }
    .fixright {
      width: 105px; 
      height: 100%;
      margin-left: 80px;  
      button {
        height: 40px;
        color: #fff;
        background-color:#444;
        border: none;
      }
    }
  }
}
</style>